/**
 * 功能描述 列表
 */

define(function (require, exports, module){
	var Grid = require("grid");
	var aw = require("ajaxwrapper");
	var Dialog = require("dialog");
	var store =require("store");
	var planfile = require("../store/planfile");
	var checkInBiz = require("../business/checkInBiz");
	
	var instance = {
		initComponent:function (params,widget){
			var grid = new Grid({
				parentNode:".J-grid",
				autoRender : false,
				model:{
					url:"api/checkinimplement/querycheckin",
					params: function() {
                    	var subnav=widget.get("subnav");
                        return {
//                        	"groupReserve.planItemGroup.checkInStatusIn":"Reserve,CheckIn",
                        	"servicePoint.pkServicePoint":subnav.getValue("servicePoint"),
    						"groupReserve.reserveDate":subnav.getValue("reserveDate").start,
    						"groupReserve.reserveDateEnd":subnav.getValue("reserveDate").end,
     						"dataSource":"GroupReserve",
     						"status":"Confirmed",
     						"groupReserve.planItemGroup.checkInStatus":subnav.getValue("checkInStatus"),
     						"orderString" : "groupReserve.checkInDate",
     						fetchProperties: planfile.fetchProperties
                        };
                    },
					columns:[{
						name:"groupReserve.reserveDate",
						label:"预约日期",
						format:"date",
						formatparams:{
							mode:"YYYY.MM.DD"
						}
					},{
						name:"groupReserve.planItemGroup.allianceOrg.name",
						label:"组团单位",
						format:function(value,row){
							if(row.groupReserve.planItemGroup.alliance){
								return value;
							}else{
								return row.groupReserve.operator.servicePoint.name;
							}
						}
					},{
						name : "groupReserve.planItemGroup.planItem.destination.name",
						label : "目的地"
					},{
						name: "groupReserve.checkInDate",
						label: "入住日期",
						format: "date"
					},{
						name: "groupReserve.checkOutDate",
						label: "退住日期",
						format: "date"
					},{
						name : "signUpNumber",
						label : "报名人数",
						format:function(data, row){
        					return row.roomPersonalInfos.length;
        				}
					},{
						name:"signstatus",
						label:"状态",
						format:function(value, row){
							if(row.groupReserve.planItemGroup.checkInStatus.key=="CheckIn"){
								return "已登记";
							}else{
								return "待登记";
							}
//        					return checkInBiz.checkInStatus(row,"待登记","已登记");        					
        				}
					},{
						name:"operate",
						label:"操作",
						format:"button",
						formatparams:[{
							id:"appointment",
							text: "登记",
							show:function(value,row){		
								if(row.roomPersonalInfos.length==0){
									return false;
								}
								if(row.groupReserve.planItemGroup.checkInStatus.key=="Reserve"){
									return true;
								}else{
									return false;
								}
							},
							handler:function(index,data,rowEle){
								widget.handler.grid.appointment(widget,data,rowEle);
							}
						},{
							id:"check",
							text: "查看",
							show:function(value,row){
								if(row.roomPersonalInfos.length==0){
									return false;
								}
								if(row.groupReserve.planItemGroup.checkInStatus.key=="CheckIn"){
									return true;
								}else{
									return false;
								}
							},
							handler:function(index,data,rowEle){
								widget.get("form").setDisabled(true);
								widget.handler.grid.check(widget,data,rowEle);
							}
						}]
					}]
				}
			});
			widget.set("grid",grid);
		}
	};
	module.exports = instance;
});
